//
//  HeadCollectionView.m
//  ProjectA_LK
//
//  Created by apple on 16/6/14.
//  Copyright © 2016年 冷坤. All rights reserved.
//

#import "HeadCollectionView.h"
#import "HeadOneCollectionView.h"
#import "NavigationModel.h"
#import "RadioViewController.h"
@implementation HeadCollectionView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatCollectionView:frame];
    }
    return self;
}

- (void)creatCollectionView:(CGRect)frame
{
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(frame.size.width / 4 - 0.25, frame.size.height);
    flowLayout.minimumInteritemSpacing = 0;
    flowLayout.minimumLineSpacing = 0;
    flowLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height) collectionViewLayout:flowLayout];
    self.collectionView.dataSource = self;
    self.collectionView.delegate = self;
    self.collectionView.backgroundColor = [UIColor whiteColor];
    [self addSubview:_collectionView];
    
    [self.collectionView registerClass:[HeadOneCollectionView class] forCellWithReuseIdentifier:@"headCollectionView"];
    
    [_collectionView release];
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.array.count + 1;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSArray *imageArray = @[[UIImage imageNamed:@"TV"], [UIImage imageNamed:@"Void"], [UIImage imageNamed:@"Ms"], [UIImage imageNamed:@"QD_n"]];

    
    
    HeadOneCollectionView *item = [collectionView dequeueReusableCellWithReuseIdentifier:@"headCollectionView" forIndexPath:indexPath];
    
    UIImage *image = imageArray[indexPath.item];
    item.imageViewPic.image = image;
    
    
    if (indexPath.item != 3) {
        NavigationModel *model = self.array[indexPath.item];
        item.labelName.text = model.name;
    }else{
        item.labelName.text = @"签到";
    }
    return item;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        
    }
}

@end










